import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    setmylongtime:"",
    time: 0,
    tabledata: [],
    // 产品到期时间  1
    ProductExpirationTime: [],
    ConsumableStatistics: [],
    AssetStatistics: [],
    OutboundRecords: [],
    warehouseId: null,
    itemPieChar: null,
    propertyPieChar: null,
    listErrorProperty: [],
    Imgdata: null,
    imgid: null
  },
  getters: {
  },
  mutations: {
    settime(state) {
      state.tiem = state;
    },
    getmytable(state) {
      state.tabledata = state
    },
    ProductExpirationTime(state, ProductExpirationTime) {
      if (ProductExpirationTime.length) {
        state.ProductExpirationTime = ProductExpirationTime;
      } else {
        state.ProductExpirationTime = null;
      }
    },
    listErrorProperty(state, listErrorProperty) {
      if (listErrorProperty.length) {
        state.listErrorProperty = listErrorProperty;
      } else {
        state.listErrorProperty = null;
      }
    },
    ConsumableStatistics(state, ConsumableStatistics) {
      if (ConsumableStatistics.length) {
        state.ConsumableStatistics = ConsumableStatistics;
      } else {
        state.ConsumableStatistics = null;
      }
    },
    AssetStatistics(state, AssetStatistics) {
      if (AssetStatistics.length) {
        state.AssetStatistics = AssetStatistics;
      } else {
        state.AssetStatistics = null;
      }
    },
    OutboundRecords(state, OutboundRecords) {
      if (
        OutboundRecords[0]?.formTpe == 41 ||
        OutboundRecords[0]?.formTpe == 42
      ) {
        state.imgid = localStorage.getItem("setmywarehouseId")
        state.Imgdata = OutboundRecords[0].fileList[0]?.url
      }
      if (OutboundRecords.length) {
        const res = JSON.parse(JSON.stringify(OutboundRecords))
        res.length ? res.reverse() : res;
        state.OutboundRecords = res;
      } else {
        state.OutboundRecords = null;
      }
    },
    itemPieChar(state, itemPieChar) {
      state.itemPieChar = itemPieChar;
    },
    propertyPieChar(state, propertyPieChar) {
      state.propertyPieChar = propertyPieChar;
    },
    setmywarehouseId(state, warehouseId) {
      state.warehouseId = warehouseId;
    }
  },
  actions: {
  },
  modules: {
  }
})
